/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * Project Name: lmrp-android app
 * Create Time: 16-2-16 下午6:42
 */

package com.lenovo.mso2o.ui.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lenovo.framework.base.BaseListAdapter;
import com.lenovo.framework.util.ViewHolder;
import com.lenovo.mso2o.R;

import java.util.List;

/**
 * Created by lenovo on 2015/11/16.
 */
public class ConditionSelectAdapter extends BaseListAdapter<String> {
    public static final String[] MAIN_CONDITION = {"按综合排序", "按距离排序"};

    /**
     * list == null, not save adater data state, list!=null, save it's state
     * util next shown
     *
     * @param list
     */

    public ConditionSelectAdapter(List<String> list) {
        super(list);
    }

    @Override
    protected View getNextView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = View.inflate(parent.getContext(), R.layout.item_orderlistcondition_selectdistance, null);
        }
        TextView textView = ViewHolder.get(convertView, R.id.text_orderlistActiveFragmentTitle_conditionDistancelistItem);
        ImageView image_checked = ViewHolder.get(convertView, R.id.image_conditionSelected_orderlist);
        String jsonString = "{\"text\": \"提前2小时提醒\", \"value\": 120}";
        //JSONObject jsonObject = new JSONObject(jsonString);
        textView.setText(getItem(position).toString());
        if (index == position) {//设置字体颜色
            textView.setTextColor(parent.getResources().getColor(R.color.blue_accent));
            image_checked.setVisibility(View.VISIBLE);
        } else {
            textView.setTextColor(parent.getResources().getColor(R.color.black_accent));
            image_checked.setVisibility(View.INVISIBLE);
        }
        return convertView;
    }

    @Override
    protected void onReachBottom() {
    }
}
